<template>
  <a-modal :visible="createVisible" @ok="handleSubmit">
    <div :style="{ display: 'flex' }">
      <a-card :style="{ width: '380px' }" :bordered="false">
        <a-form
          :model="createform"
          :style="{ width: '340px' }"
          @submit="handleSubmit"
        >
          <a-form-item field="username" label="姓名">
            <a-input
              v-model="createform.username"
              placeholder="请输入租户姓名"
            />
          </a-form-item>
          <a-form-item field="password" label="密码">
            <a-input v-model="createform.password" placeholder="请输入密码" />
          </a-form-item>
          <a-form-item field="mobile" label="手机号">
            <a-input v-model="createform.mobile" placeholder="请输入手机号" />
          </a-form-item>
          <a-form-item field="email" label="邮箱">
            <a-input v-model="createform.email" placeholder="请输入邮箱" />
          </a-form-item>
          <a-form-item field="nickname" label="昵称">
            <a-input v-model="createform.nickname" placeholder="请输入昵称" />
          </a-form-item>
        </a-form>
      </a-card>
    </div>
  </a-modal>
</template>

<script setup>
  import { ref } from 'vue-demi';
  import { register } from '@/api/user';

  const createform = ref({
    username: '',
    password: '',
    email: '',
    mobile: '',
    nickname: '',
    role: '1',
  });
  const handleSubmit = async () => {
    //  createform.value
    console.log('sub');
    await register(createform.value);
  };
</script>
